package com.jt.www.admin.order_wxb.controller;

import com.jt.www.admin.order_wxb.service.impl.WxbService;
import com.jt.www.annotations.AddHeader;
import com.jt.www.domain.qo.ConfirmPolicyQo;
import com.jt.www.domain.qo.InvoiceQDXPXQo;
import com.jt.www.model.reps.GenericResponse;
import com.jt.www.model.reps.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by shaoyn on 2020/09/16.
 */
@Api(value = "我学保相关", tags = {"WXB-API"}, description = "我学保相关")
@RestController
@RequestMapping(value = "/wxb")
public class WxbController {

    public static final Logger log = LoggerFactory.getLogger(WxbController.class);

    @Autowired
    private WxbService wxbService;

    /**
     * 重复投保校验
     */
    @AddHeader
    @ApiOperation(value = "重复投保校验", notes = "重复投保校验", httpMethod = "POST")
    @PostMapping(value = "/repeatInsurance", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResponseData repeatInsurance(@RequestBody ConfirmPolicyQo confirmPolicyQo) {
        try {
            return wxbService.repeatInsurance(confirmPolicyQo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        ResponseData responseData = new ResponseData();
        responseData.setCode(GenericResponse.CODE_NG);
        return responseData;
    }

    @ApiOperation(value = "启东学平险获取电子发票", notes = "启东学平险获取电子发票", httpMethod = "POST")
    @PostMapping(value = "/downInvoiceQDXPX", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResponseData downInvoiceQDXPX(@RequestBody InvoiceQDXPXQo invoiceQDXPXQo) {
        try {
            return wxbService.downInvoiceQDXPX(invoiceQDXPXQo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        ResponseData responseData = new ResponseData();
        responseData.setCode(GenericResponse.CODE_NG);
        return responseData;
    }
}
